package com.cotte.flow.repository;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class OracleRepository {
	@Autowired
	@Qualifier("oracle")
	JdbcTemplate oracle;
	
	public Integer getScddhxppjgid(String syscode, String cate) {
		String scddhxppjgidSql = "select c.scddhxppjgid"
				+ " from t_scdd a,t_scddpzmx b,t_scddhxppjg c,c_fzfl d"
				+ " where a.scddid=b.scddid and b.scddpzmxid=c.scddpzmxid"
				+ " and b.fzflid=d.fzflid" + " and a.ecode='" + syscode + "'"
				+ " and d.ecode='" + cate + "'";
		Map<String, Object> scddhxppjgidMap = oracle
				.queryForMap(scddhxppjgidSql);
		Integer scddhxppjgid = Integer.parseInt(scddhxppjgidMap.get(
				"scddhxppjgid").toString());
		return scddhxppjgid;
	}

	public List<Map<String, Object>> getStepList(Integer scddhxppjgid) {
		String stepSql = "select distinct c.ecode"
				+ " from t_scddhxppjgpzgy a,c_gyflsjxxgxxx b,c_gxdn c"
				+ " where a.gyflsjxxid=b.gyflsjxxid and b.gxid=c.gxid"
				+ " and a.scddhxppjgid=" + scddhxppjgid;
		List<Map<String, Object>> stepMap = oracle.queryForList(stepSql);
		return stepMap;
	}
}
